<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
    $api->group([
        'namespace' => '\\App\\Api\\Controllers',
    ], function ($api) {
        $api->post('/auth/login', 'AuthController@login'); //登录
        $api->post('/auth/wxsave', 'AuthController@wxsave'); //微信登录
        $api->post('/auth/proxy', 'AuthController@proxyLogin'); //代理登录

        $api->post('upfile', 'AuthController@upfile'); //上传
        $api->post('uploads', 'IndexController@uploads'); // 文件上传

        // 公共接口
        $api->post('sms', 'AuthController@smsCode'); // 短信 验证码
        $api->post('area', 'IndexController@area');

        $api->post('/test','IndexController@test'); // 意见反馈

        //商城接口
        $api->post('shop/banner', 'ShopController@banner'); //商城banner
        $api->post('shop/cate', 'ShopController@cate');     //商城分类

        $api->post('products/detail', 'ShopController@detail'); //产品详情
        $api->post('/about','IndexController@about'); // 关于

        $api->post('/wxnotify','PayController@wxNotify'); //支付回调

        $api->post('/service','IndexController@service'); //支付回调
        $api->post('/jd/notify','IndexController@jdback'); //京东回调
        $api->post('/jd/express','IndexController@jdExpress'); //京东物流

        //获取登录用户的收货地址列表
        $api->group(['middleware' => ['refresh.token']], function ($api) {
            $api->post('/order/postfee','OrderController@postFee'); //快递费计算

            $api->post('shop/products', 'ShopController@products'); //商城产品列表
            $api->post('shop/hot/products', 'ShopController@hotProducts'); //商城热门产品

            $api->post('products/sku', 'ShopController@productSku'); //产品详情
            $api->post('products/comments', 'ShopController@ProductComment'); //产品详情
            //购物车
            $api->post('cart/opt', 'CartController@add'); //添加
            $api->post('cart/index', 'CartController@index'); //列表
            $api->post('cart/stock', 'CartController@stock'); //库存判断
            $api->post('cart/del', 'CartController@del'); //删除
            //订单接口
            $api->post('order/check','OrderController@orderCheck'); //订单提交检查
            $api->post('order/add','OrderController@add'); //创建订单
            $api->post('order/close','OrderController@close'); //取消订单
            $api->post('order/index','OrderController@index'); //订单列表
            $api->post('order/detail','OrderController@detail'); //订单详情
            $api->post('order/receive','OrderController@receive'); //确认收货
            $api->post('order/tip','OrderController@tip'); //发送发货提醒
            $api->post('order/create/review','OrderController@createReview'); //订单评价
            $api->post('order/review','OrderController@viewReview'); //查看评价
            $api->post('/order/refound','OrderController@refund'); //订单申请退款
            $api->post('/order/pay','PayController@order'); //订单支付
            //用户接口
            $api->post('/user/money/log','UserController@moneyLog'); //资金明细
            $api->post('/user/score/log','UserController@scoreLog'); //积分明细


            $api->post('/user/info','UserController@info'); //用户中心-我的

            $api->post('/user/message','UserController@messages'); // 系统消息列表
            $api->post('/user/feedback','UserController@feedback'); // 意见反馈
            $api->post('/user/logout','UserController@logout'); // 退出

            //收货地址
            $api->get('user_address', 'UserAddressesController@index'); //地址列表
            $api->post('user_address/detail', 'UserAddressesController@show');//地址详情
            $api->post('user_address', 'UserAddressesController@store'); //添加地址
            $api->post('user_address/update', 'UserAddressesController@update');//修改地址
            $api->post('user_address/del', 'UserAddressesController@destroy');//删除地址
            $api->post('user_address/default', 'UserAddressesController@setDefault');//设置默认地址

        });
    });
});
